package com.zheng.cloud.Proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 事务处理器
 */
public class TimeHandler implements InvocationHandler {

    private Object target;

    public TimeHandler(Object target) {
        super();
        this.target = target;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        long startTime = System.currentTimeMillis();
        System.out.println("小汽车运行开始 ……");
        method.invoke(target, args);
        long stopTime = System.currentTimeMillis();
        System.out.println("小汽车运行结束，耗时：" + (stopTime - startTime));
        return null;
    }
}
